package boot.service.impl.wxGoodsCategory;

import boot.dao.GoodscategoryMapper;
import boot.domain.wxGoodsCategory.Goodscategory;
import boot.domain.wxGoodsCategory.GoodscategoryExample;
import boot.service.wxGoodsCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class wxGoodsCategoryServiceImpl implements wxGoodsCategoryService {
    @Autowired
    private GoodscategoryMapper goodscategoryMapper;
    @Override
    public int findId(String name) {
        GoodscategoryExample goodscategoryExample = new GoodscategoryExample();
        GoodscategoryExample.Criteria criteria = goodscategoryExample.createCriteria();
        criteria.andNameEqualTo(name);
        return goodscategoryMapper.selectByExample(goodscategoryExample).get(0).getId();
    }

    @Override
    public void addCate(String name) {
        Goodscategory goodscategory = new Goodscategory(null,name);
        goodscategoryMapper.insert(goodscategory);
    }

    @Override
    public List<Goodscategory> getAllCate() {
        GoodscategoryExample goodscategoryExample = new GoodscategoryExample();
        return goodscategoryMapper.selectByExample(goodscategoryExample);
    }
}
